﻿@page "/identity/roles"
@attribute [Authorize(IdentityPermissions.Roles.Default)]
@namespace  ERP.Abp.IdentityManagement.Blazor.AntDesignUI.Pages
@using ERP.Abp.IdentityManagement.Blazor.AntDesignUI.Pages
@using Microsoft.AspNetCore.Authorization
@using ERP.Abp.PermissionManagement.Blazor.AntDesignUI
@using Volo.Abp.AspNetCore.Components.Web
@using ERP.Abp.Identity
@using ERP.Abp.Identity.Localization
@using  ERP.Abp.PermissionManagement.Blazor.AntDesignUI.Components
@inject AbpBlazorMessageLocalizerHelper<IdentityResource> LH
@inherits AbpCrudPageBase<IIdentityRoleAppService, IdentityRoleDto, Guid, GetIdentityRolesInput, IdentityRoleCreateDto, IdentityRoleUpdateDto>

 
 <GridContent>
    <AntDesign.Card  >
         <AdminTable   TItem="IdentityRoleDto"  Columns="RoleManagementTableColumns"  OnChange="OnDataGridReadAsync"  RemoteDataSource="true"  DataSource="@Entities"  Total="@TotalCount"  PageSize="@PageSize"  PageIndex= "@CurrentPage"   Loading="@Loading" >
            <SearchTemplate>
                  <AntDesign.Form  Model="GetListInput" TModel="GetIdentityRolesInput" Name="advanced_search" Class="ant-advanced-search-form">
                    <AntDesign.Row Gutter="24">
                            <AntDesign.GridCol Span="8"  >
                                <FormItem Label="@($"角色名")" >
                                  <AntDesign.Input @bind-Value="@(context.Filter)" OnPressEnter="SearchEntitiesAsync" OnFocus="SearchEntitiesAsync" Placeholder="placeholder" /> 
                                </FormItem>
                            </AntDesign.GridCol>
                    </AntDesign.Row>
                </AntDesign.Form>
            </SearchTemplate>
            <ToolbarRightButtonTemplate  >
                    <AntDesign.ButtonGroup>
                         <AntDesign.Button Icon="@IconType.Outline.Plus" Type="primary" OnClick="OpenCreateModalAsync" >@L["NewUser"]</AntDesign.Button>
                        <AntDesign.Button Icon="@IconType.Outline.Search" Type="primary" OnClick=" SearchEntitiesAsync" >查询</AntDesign.Button>
                     </AntDesign.ButtonGroup>
            </ToolbarRightButtonTemplate>
        </AdminTable>
    </AntDesign.Card>
</GridContent>




@if (HasCreatePermission)
{
    <Modal @ref="CreateModal" Title="@L["NewRole"]" Visible="@CreateModalVisible" OnCancel="@CloseCreateModalAsync" OnOk="CreateEntityAsync">
        <Form
            Layout="@FormLayout.Vertical"
            @ref="@CreateFormRef"
            Model="@NewEntity">
            <FormItem Label="@L["DisplayName:RoleName"]">
                <Input @bind-Value="@context.Name"/>
            </FormItem>
            <FormItem>
                <Checkbox @bind-Value="context.IsDefault">@L["DisplayName:IsDefault"]</Checkbox>
            </FormItem>
            <FormItem>
                <Checkbox @bind-Value="context.IsPublic">@L["DisplayName:IsPublic"]</Checkbox>
            </FormItem>
        </Form>
    </Modal>
}

@if (HasUpdatePermission)
{
    <Modal @ref="EditModal" Title="@L["Edit"]" Visible="@EditModalVisible" OnCancel="@CloseEditModalAsync" OnOk="UpdateEntityAsync">
        <Form
            Layout="@FormLayout.Vertical"
            @ref="@EditFormRef"
            Model="@EditingEntity">
            <input type="hidden" name="ConcurrencyStamp" @bind-value="EditingEntity.ConcurrencyStamp"/>
            <FormItem Label="@L["DisplayName:RoleName"]">
                <Input @bind-Value="@context.Name"/>
            </FormItem>
            <FormItem>
                <Checkbox @bind-Value="context.IsDefault">@L["DisplayName:IsDefault"]</Checkbox>
            </FormItem>
            <FormItem>
                <Checkbox @bind-Value="context.IsPublic">@L["DisplayName:IsPublic"]</Checkbox>
            </FormItem>
        </Form>
    </Modal>
}


@if (HasManagePermissionsPermission)
{
    <PermissionManagementModal @ref="PermissionManagementModal"/>
}

 